import com.atguigu.realtime.bean.KeywordBean;

import java.lang.reflect.Field;

/**
 * @Author lzc
 * @Date 2022/7/25 10:06
 */
public class Demo4 {
    public static void main(String[] args) throws NoSuchFieldException, IllegalAccessException {
        Class<KeywordBean> tClass = KeywordBean.class;
        KeywordBean bean = new KeywordBean();
        bean.setStt("abc");
        //System.out.println(bean.stt);
    
        //        Field[] fields = tClass.getDeclaredFields();
    
        /*String names = "";
        for (Field field : fields) {
            names += field.getName() + ",";
        }
        System.out.println(names.substring(0, names.length() - 1));*/
    
//        String names = Arrays.stream(fields).map(Field::getName).collect(Collectors.joining(","));
//        System.out.println(names);
    
        Field stt = tClass.getDeclaredField("stt");
        stt.setAccessible(true);// 强制允许访问私有属性
//        Object v = stt.get(bean);
        
        stt.set(bean,"ffff");
    
        System.out.println(bean);
    
    
    }
}
